/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * <p>Project: jse2302 - BufferedReaderDemo
 * <p>Powered by webrx On 2023-06-28 11:42:36
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class BufferedReaderDemo {
    public static void main(String[] args) {

        //写入文件
        try(var o = new BufferedWriter(new FileWriter("m.txt",true))){
            o.write("hello1\r\n");
            o.write("hello2\r\n");
            o.write("hello3\r\n");
            o.write("hello4\r\n");
            o.write("hello5\r\n");
        }catch(Exception e){
            e.printStackTrace();
        }


        //读取文件
        String f = "D:\\0531\\javase\\jse2302\\ch09\\src\\cn\\webrx\\Demo.java";
        try(var buf = new BufferedReader(new FileReader(f))){
            int num = 0;
            while(buf.ready()){

                System.out.printf("%02d、%s%n",++num,buf.readLine());
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
